package com.limingru.online_class.common;

public class ResultGenerator {
    private static final int DEFAULT_SUCCESS_CODE = 200;

    private static final int DEFAULT_FAIL_CODE = 500;

    private static final String DEFAULT_SUCCESS_MSG = "success";

    private static final String DEFAULT_FAIL_MSG = "fail";

    public static Result generateSuccessResult() {
        return new Result(DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MSG);
    }

    public static Result generateSuccessResult(Object data) {
        Result result = new Result();
        result.setCode(DEFAULT_SUCCESS_CODE);
        result.setMsg(DEFAULT_SUCCESS_MSG);
        result.setData(data);
        return result;
    }

    public static Result generateFailResult() {
        return new Result(DEFAULT_FAIL_CODE, DEFAULT_FAIL_MSG);
    }

    public static Result generateFailResult(String msg) {
        return new Result(DEFAULT_FAIL_CODE, msg);
    }

    public static Result generateFailResult(int code, String msg) {
        return new Result(code, msg);
    }

}
